use "firstdaughtereffect.dta", clear

svyset [pw=weight]

*gender recode
gen gender2=gender
recode gender2 2=0

*age recode
gen age=(2016-birthyr)/93
tab age

*education recode 0-1
recode educ (1=0) (2=.20) (3=.40) (4=.60) (5=.80) (6=1), gen(education)
tab education educ

*white recode
gen white = race
recode white (1=1) (2/8=0)
tab white
tab race

*marriage recode
gen married = marstat
recode married (1=1) (2/6=0)
tab married
tab marstat

*sexuality recode
gen newsexuality=sexuality
recode newsexuality 2/6=0
tab newsexuality
tab sexuality

*income recode
gen income = faminc
recode income (97/99=.)
recode income 31=12
gen newincome=income
recode newincome 1=.0625 2=.125 3=.1875 4=.25 5=.3125 6=.375 7=.4375 8=.50 9=.5625 10=.625 11=.6875 12=.75 13=.8125 14=.875 15=.9375 16=1
tab newincome
tab faminc

*partyid recode (0 to 1 with 1 = Republican)
recode pid7 (8=4), gen(partyid7) 
recode partyid7 (1=0) (2=.16) (3=.32) (4=.48) (5=.64) (6=.80) (7=1)
tab partyid7 
tab pid7

* ideology recode (0-1 with Conservative at 1)
recode ideo5 (6=.), gen(newideology)
recode newideology (1=0) (2=.25) (3=.5) (4=.75) (5=1)
tab newideology
tab ideo5

*sisters recode
gen sister = UMA312b_1
recode sister (0=0) (1/max=1)  
tab sister
tab UMA312b_1

*children recode
gen children = UMA313
recode children (0=0) (1/50=1)
tab children UMA313
tab UMA313
tab children

*father
gen father = .
replace father = 1 if (gender==1 & children==1)
replace father = 0 if (gender==1 & children==0)
tab father
tab gender children

* mother
gen mother = .
replace mother = 1 if (gender==2 & children==1)
replace mother = 0 if (gender==2 & children==0)
tab mother
tab gender children

*parent
gen parent = .
replace parent = 1 if (father==1)
replace parent = 1 if (mother==1)
replace parent = 0 if (father==0)
replace parent = 0 if (mother==0)
tab parent 

*daughter (binary)
gen daughter = . 
replace daughter = 1 if (Child1B==4)
replace daughter = 1 if (Child2B==4)
replace daughter = 1 if (Child3B==4)
replace daughter = 1 if (Child4B==4)
replace daughter = 1 if (Child5B==4)
replace daughter = 0 if (daughter~=1) 
tab daughter
tab Child1B
tab Child2B
tab Child3B
tab Child4B
tab Child5B

*son (binary)
gen son = . 
replace son = 1 if (Child1B==3)
replace son = 1 if (Child2B==3)
replace son = 1 if (Child3B==3)
replace son = 1 if (Child4B==3)
replace son = 1 if (Child5B==3)
replace son = 0 if (son~=1) 
tab son
tab Child1B
tab Child2B
tab Child3B
tab Child4B
tab Child5B

*One Respondent indicates that they have a daughter, but not a parent of a child
drop if parent==0 & daughter==1

*get rid if number of children is greater than 5 (about 2.25% of respondents)
drop if UMA313 > 5

*number of daughters
gen numberdaughtersX = .
*all combinations of 1 daughter
replace numberdaughtersX = 1 if (UMA313==1 & Child1B==4)

replace numberdaughtersX = 1 if (UMA313==2 & Child1B==3 & Child2B==4)
replace numberdaughtersX = 1 if (UMA313==2 & Child1B==4 & Child2B==3)

replace numberdaughtersX = 1 if (UMA313==3 & Child1B==4 & Child2B==3 & Child3B==3)
replace numberdaughtersX = 1 if (UMA313==3 & Child1B==3 & Child2B==4 & Child3B==3)
replace numberdaughtersX = 1 if (UMA313==3 & Child1B==3 & Child2B==3 & Child3B==4)

replace numberdaughtersX = 1 if (UMA313==4 & Child1B==4 & Child2B==3 & Child3B==3 & Child4B==3)
replace numberdaughtersX = 1 if (UMA313==4 & Child1B==3 & Child2B==4 & Child3B==3 & Child4B==3)
replace numberdaughtersX = 1 if (UMA313==4 & Child1B==3 & Child2B==3 & Child3B==4 & Child4B==3)
replace numberdaughtersX = 1 if (UMA313==4 & Child1B==3 & Child2B==3 & Child3B==3 & Child4B==4)

replace numberdaughtersX = 1 if (UMA313==5 & Child1B==4 & Child2B==3 & Child3B==3 & Child4B==3 & Child5B==3)
replace numberdaughtersX = 1 if (UMA313==5 & Child1B==3 & Child2B==4 & Child3B==3 & Child4B==3 & Child5B==3)
replace numberdaughtersX = 1 if (UMA313==5 & Child1B==3 & Child2B==3 & Child3B==4 & Child4B==3 & Child5B==3)
replace numberdaughtersX = 1 if (UMA313==5 & Child1B==3 & Child2B==3 & Child3B==3 & Child4B==4 & Child5B==3)
replace numberdaughtersX = 1 if (UMA313==5 & Child1B==3 & Child2B==3 & Child3B==3 & Child4B==3 & Child5B==4)

*all combinations of 2 daughters
replace numberdaughtersX = 2 if (UMA313==2 & Child1B==4 & Child2B==4)

replace numberdaughtersX = 2 if (UMA313==3 & Child1B==4 & Child2B==4 & Child3B==3)
replace numberdaughtersX = 2 if (UMA313==3 & Child1B==4 & Child2B==3 & Child3B==4)
replace numberdaughtersX = 2 if (UMA313==3 & Child1B==3 & Child2B==4 & Child3B==4)

replace numberdaughtersX = 2 if (UMA313==4 & Child1B==4 & Child2B==4 & Child3B==3 & Child4B==3)
replace numberdaughtersX = 2 if (UMA313==4 & Child1B==4 & Child2B==3 & Child3B==4 & Child4B==3)
replace numberdaughtersX = 2 if (UMA313==4 & Child1B==4 & Child2B==3 & Child3B==3 & Child4B==4)
replace numberdaughtersX = 2 if (UMA313==4 & Child1B==3 & Child2B==4 & Child3B==4 & Child4B==3)
replace numberdaughtersX = 2 if (UMA313==4 & Child1B==3 & Child2B==4 & Child3B==3 & Child4B==4)
replace numberdaughtersX = 2 if (UMA313==4 & Child1B==3 & Child2B==3 & Child3B==4 & Child4B==4)

replace numberdaughtersX = 2 if (UMA313==5 & Child1B==4 & Child2B==4 & Child3B==3 & Child4B==3 & Child5B==3)
replace numberdaughtersX = 2 if (UMA313==5 & Child1B==4 & Child2B==3 & Child3B==4 & Child4B==3 & Child5B==3)
replace numberdaughtersX = 2 if (UMA313==5 & Child1B==4 & Child2B==3 & Child3B==3 & Child4B==4 & Child5B==3)
replace numberdaughtersX = 2 if (UMA313==5 & Child1B==4 & Child2B==3 & Child3B==3 & Child4B==3 & Child5B==4)
replace numberdaughtersX = 2 if (UMA313==5 & Child1B==3 & Child2B==4 & Child3B==4 & Child4B==3 & Child5B==3)
replace numberdaughtersX = 2 if (UMA313==5 & Child1B==3 & Child2B==4 & Child3B==3 & Child4B==4 & Child5B==3)
replace numberdaughtersX = 2 if (UMA313==5 & Child1B==3 & Child2B==4 & Child3B==3 & Child4B==3 & Child5B==4)
replace numberdaughtersX = 2 if (UMA313==5 & Child1B==3 & Child2B==3 & Child3B==4 & Child4B==4 & Child5B==3)
replace numberdaughtersX = 2 if (UMA313==5 & Child1B==3 & Child2B==3 & Child3B==4 & Child4B==3 & Child5B==4)
replace numberdaughtersX = 2 if (UMA313==5 & Child1B==3 & Child2B==3 & Child3B==3 & Child4B==4 & Child5B==4)

*all combinations of 3 daughters
replace numberdaughtersX = 3 if (UMA313==3 & Child1B==4 & Child2B==4 & Child3B==4)

replace numberdaughtersX = 3 if (UMA313==4 & Child1B==4 & Child2B==4 & Child3B==4 & Child4B==3)
replace numberdaughtersX = 3 if (UMA313==4 & Child1B==4 & Child2B==4 & Child3B==3 & Child4B==4)
replace numberdaughtersX = 3 if (UMA313==4 & Child1B==4 & Child2B==3 & Child3B==4 & Child4B==4)
replace numberdaughtersX = 3 if (UMA313==4 & Child1B==3 & Child2B==4 & Child3B==4 & Child4B==4)


replace numberdaughtersX = 3 if (UMA313==5 & Child1B==4 & Child2B==4 & Child3B==4 & Child4B==3 & Child5B==3)
replace numberdaughtersX = 3 if (UMA313==5 & Child1B==4 & Child2B==4 & Child3B==3 & Child4B==4 & Child5B==3)
replace numberdaughtersX = 3 if (UMA313==5 & Child1B==4 & Child2B==4 & Child3B==3 & Child4B==3 & Child5B==4)
replace numberdaughtersX = 3 if (UMA313==5 & Child1B==4 & Child2B==4 & Child3B==3 & Child4B==3 & Child5B==4)
replace numberdaughtersX = 3 if (UMA313==5 & Child1B==3 & Child2B==4 & Child3B==4 & Child4B==4 & Child5B==3)
replace numberdaughtersX = 3 if (UMA313==5 & Child1B==3 & Child2B==4 & Child3B==4 & Child4B==3 & Child5B==4)
replace numberdaughtersX = 3 if (UMA313==5 & Child1B==3 & Child2B==3 & Child3B==4 & Child4B==4 & Child5B==4)
replace numberdaughtersX = 3 if (UMA313==5 & Child1B==3 & Child2B==4 & Child3B==3 & Child4B==4 & Child5B==4)
replace numberdaughtersX = 3 if (UMA313==5 & Child1B==3 & Child2B==4 & Child3B==4 & Child4B==3 & Child5B==4)

*all combinations of 4 daughters
replace numberdaughtersX = 4 if (UMA313==4 & Child1B==4 & Child2B==4 & Child3B==4 & Child4B==4)

replace numberdaughtersX = 4 if (UMA313==5 & Child1B==4 & Child2B==4 & Child3B==4 & Child4B==4 & Child5B==3)
replace numberdaughtersX = 4 if (UMA313==5 & Child1B==4 & Child2B==4 & Child3B==4 & Child4B==3 & Child5B==4)
replace numberdaughtersX = 4 if (UMA313==5 & Child1B==4 & Child2B==4 & Child3B==3 & Child4B==4 & Child5B==4)
replace numberdaughtersX = 4 if (UMA313==5 & Child1B==4 & Child2B==3 & Child3B==4 & Child4B==4 & Child5B==4)
replace numberdaughtersX = 4 if (UMA313==5 & Child1B==3 & Child2B==4 & Child3B==4 & Child4B==4 & Child5B==4)

*all combinations of 5 daughters
replace numberdaughtersX = 5 if (UMA313==5 & Child1B==4 & Child2B==4 & Child3B==4 & Child4B==4 & Child5B==4)

replace numberdaughtersX = 0 if (Child1B~=4 & Child2B~=4 & Child3B~=4 & Child4B~=4 & Child5B~=4)

gen numberdaughters3 = numberdaughtersX/5
tab numberdaughters3

*fathers with daughters (0 is fathers without daughters)
gen fatherdaughter = .
replace fatherdaughter = 1 if (father==1 & daughter==1)
replace fatherdaughter = 0 if (father==1 & daughter~=1)
tab fatherdaughter
tab father daughter

*fathers with first daughter (0 are fathers without first daughter)
gen fatherfirstdaughter = .
replace fatherfirstdaughter = 1 if (father==1 & Child1B==4)
replace fatherfirstdaughter = 0 if (father==1 & Child1B~=4)
tab father Child1B
tab fatherfirstdaughter

*firstdaughter
gen firstdaughter=. 
replace firstdaughter = 1 if (parent==1 & Child1B==4)
replace firstdaughter = 0 if (parent==1 & Child1B~=4)

*parentdaughter
gen parentdaughter=. 
replace parentdaughter = 1 if (parent==1 & daughter==1)
replace parentdaughter = 0 if (parent==1 & daughter~=1)
tab parentdaughter

*proportion of children that are daughters
gen numberchildren=UMA313
gen proportiondaughters=numberdaughtersX/numberchildren
tab proportiondaughters

*importance of religion
gen religimp=pew_religimp
recode religimp 1=4 2=3 3=2 4=1
recode religimp 1=0 2=.33 3=.67 4=1

*Gender Equality Scale (1= support for gender equality)
gen ge1 = UMA321a
recode ge1 (1=0) (2=.25) (3=.5) (4=.75) (5=1)
tab ge1
tab UMA321a

gen ge2 = UMA321b
recode ge2 (1=1) (2=.75) (3=.5) (4=.25) (5=0)
tab ge2
tab UMA321b

gen ge3 = UMA321c
recode ge3 (1=0) (2=.25) (3=.5) (4=.75) (5=1)
tab ge3
tab UMA321c

gen ge4 = UMA321d
recode ge4 (1=1) (2=.75) (3=.5) (4=.25) (5=0)
tab ge4
tab UMA321d

alpha ge1 ge2 ge3 ge4, gen(genderequalityscale)


*Hostile Sexism Scale (1= Oppose to Hostile Sexism)
gen hostile1=UMA306a
recode hostile1 (1=1) (2=.75) (3=.5) (4=.25) (5=0)

gen hostile2=UMA306b
recode hostile2 (1=1) (2=.75) (3=.5) (4=.25) (5=0)

gen hostile3=UMA306c
recode hostile3 (1=1) (2=.75) (3=.5) (4=.25) (5=0)

gen hostile4=UMA306d
recode hostile4 (1=1) (2=.75) (3=.5) (4=.25) (5=0)

alpha hostile1 hostile2 hostile3 hostile4, gen(hostilesexismscale)


*Dependent Variables****Index of Female Policies (1= support for female policy)
gen titleix = UMA411
recode titleix (1=1) (2=.75) (3=.5) (4=.25) (5=0) (.=.)
tab titleix
tab UMA411

gen payequity = UMA412
recode payequity (1=1) (2=.75) (3=.5) (4=.25) (5=0) (.=.)
tab payequity
tab UMA412

gen sexhar = UMA413
recode sexhar (1=1) (2=.75) (3=.5) (4=.25) (5=0) (.=.)
tab sexhar
tab UMA413

alpha titleix payequity sexhar, gen(femalepolicyindex)


*Placebo Test DVs
***gun control placebo test
gen gun1=CC16_330a
recode gun1 2=0 8/9=. 

gen gun2=CC16_330b
recode gun2 1=0 2=1 8/9=.  

gen gun3=CC16_330d
recode gun3 2=0 8/9=. 
 
gen gun4=CC16_330e
recode gun4 1=0 2=1 8/9=. 

gen gunscale = (gun1 + gun2 + gun3 + gun4)/4
tab gunscale

gen enviro1=CC16_333a
recode enviro1 2=0 8/9=. 

gen enviro2=CC16_333b
recode enviro2 2=0 8/9=. 

gen enviro3=CC16_333c
recode enviro3 2=0 8/9=. 

gen enviro4=CC16_333d
recode enviro4 2=0 8/9=. 

gen environmentscale = (enviro1 + enviro2 + enviro3 + enviro4)/4
tab environmentscale

gen immig1=CC16_331_1
recode immig1 2=0 8/9=. 

gen immig2=CC16_331_2
recode immig2 1=0 2=1 8/9=. 

gen immig3=CC16_331_3
recode immig3 2=0 8/9=. 

gen immig4=CC16_331_7
recode immig4 1=0 2=1 8/9=. 

generate immigrationscale = (immig1 + immig2 + immig3 + immig4)/4
tab immigrationscale

*came of age (18 years old) after Title IX
gen age2=2016-birthyr
gen titleIXadult=age2
tab titleIXadult
recode titleIXadult 0/62=1 63/93=0
tab titleIXadult

*had child after Title IX
gen titleIXchild=Child1A 
recode titleIXchild 1947/1971=0 1972/max=1
tab titleIXchild

*differentiating young from older fathers
gen ageBecamefather=Child1A-birthyr

recode ageBecamefather -9/14=.
tab ageBecamefather  

*Age Became Father2
gen agebecamefather2 = ageBecamefather/54
tab agebecamefather2

*Young Father (Impressionable Years vs. Older)
gen youngFather=ageBecamefather
recode youngFather 15/25=1 26/max=0
tab youngFather

*Age of First Child
gen ageoffirstchild=(2016-Child1A)/69
tab ageoffirstchild

*Age of First Daughter
gen ageoffirstdaughter = ageoffirstchild if Child1B==4
tab ageoffirstdaughter




*Table 1 
*All Parents (Mothers and Fathers )

*Model 1 of Table 1
svy: regress femalepolicyindex i.gender2  white age education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister i.parentdaughter c.proportiondaughters i.firstdaughter if newsexuality==1 

*Model 2 of Table 1
set level 84
svy: regress femalepolicyindex i.gender2  white age education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister i.parentdaughter c.proportiondaughters i.firstdaughter i.gender2##i.parentdaughter i.gender2##c.proportiondaughters  i.gender2##i.firstdaughter if newsexuality==1 

*Figure 1 
margins gender2, at(firstdaughter=(0(1)1)) vsquish
marginsplot, recast(line) recastci(rarea)

*fathers only
*Model 3 of Table 1
set level 95
svy: regress femalepolicyindex white age  education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter proportiondaughters firstdaughter if father==1 & gender==1 & newsexuality==1

*Model 4 of Table 1
*mothers only
svy: regress femalepolicyindex white age education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter proportiondaughters firstdaughter if mother==1 & gender==2 & newsexuality==1

**Table 2 
*Entropy Balancing Model - Heterosexual Fathers Only

*To replicate the entropy balancing results you will first need to install the ebal program
findit ebal

*then follow directions to install "'EBALANCE': model to perform Entropy reweighting to create balanced samples"

*entropy balancing prep

gen treat=firstdaughter
gen gendereq=genderequalityscale
gen hostile=hostilesexismscale
gen ideo=newideology
gen relig=religimp
gen parentdaug=parentdaughter

foreach v in white age education newincome partyid7 ideo relig gendereq hostile married sister parentdaug {
foreach m in white age education newincome partyid7 ideo relig gendereq hostile married sister parentdaug {
gen `v'X`m' = `v'*`m' 
} 
} 

foreach v in age education newincome partyid7 ideo relig gendereq hostile {
gen `v'X`v'X`v' = `v'^3
}


*entropy balancing model
ebalance treat white age newsexuality education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter whiteXage whiteXeducation whiteXnewincome whiteXpartyid7 whiteXideo whiteXrelig whiteXgendereq whiteXhostile whiteXmarried whiteXsister whiteXparentdaug ageXage ageXeducation ageXnewincome ageXpartyid7 ageXideo ageXrelig ageXgendereq ageXhostile ageXmarried ageXsister ageXparentdaug educationXeducation educationXnewincome educationXpartyid7 educationXideo educationXrelig educationXgendereq educationXhostile educationXmarried educationXsister educationXparentdaug newincomeXnewincome newincomeXpartyid7 newincomeXideo newincomeXrelig newincomeXgendereq newincomeXhostile newincomeXmarried newincomeXsister newincomeXparentdaug partyid7Xpartyid7 partyid7Xideo partyid7Xrelig partyid7Xgendereq partyid7Xhostile partyid7Xmarried partyid7Xsister partyid7Xparentdaug ideoXideo ideoXrelig ideoXgendereq ideoXhostile ideoXmarried ideoXsister ideoXparentdaug religXrelig religXgendereq religXhostile religXmarried religXsister religXparentdaug gendereqXgendereq gendereqXhostile gendereqXmarried gendereqXsister gendereqXparentdaug hostileXhostile hostileXmarried hostileXsister hostileXparentdaug marriedXsister marriedXparentdaug sisterXparentdaug ageXageXage educationXeducationXeducation newincomeXnewincomeXnewincome partyid7Xpartyid7Xpartyid7 ideoXideoXideo religXreligXrelig gendereqXgendereqXgendereq hostileXhostileXhostile if father==1 & gender==1 & newsexuality==1, tolerance(1.25)

*regression model with entropy balanced data
regress femalepolicyindex white age education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter treat [pweight=_webal] if father==1 & gender==1 & newsexuality==1

** Table 3
*Placebo Tests
svy: regress immigrationscale white age education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter proportiondaughters firstdaughter if father==1 & gender==1 & newsexuality==1
svy: regress environmentscale white age  education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter proportiondaughters firstdaughter if father==1 & gender==1 & newsexuality==1
svy: regress gunscale white age  education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter proportiondaughters firstdaughter if father==1 & gender==1 & newsexuality==1

* Table 4

*fathers broken down by partyid
svy: regress femalepolicyindex white age education newincome  newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter proportiondaughters firstdaughter if father==1 & gender==1 & partyid7 >.48 & newsexuality==1
svy: regress femalepolicyindex white age education newincome  newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter proportiondaughters firstdaughter if father==1 & gender==1 & partyid7 <.47 & newsexuality==1
svy: regress femalepolicyindex white age education newincome c.partyid7 newideology religimp genderequalityscale hostilesexismscale married sister i.parentdaughter c.proportiondaughters i.firstdaughter i.firstdaughter##c.partyid7 i.parentdaughter##c.partyid7 c.proportiondaughters##c.partyid7 i.firstdaughter##c.partyid7 if pid7~=4 & father==1 & gender==1 & newsexuality==1 & pid7~=8 

*Table 5
*fathers by age (dads who come of age before Title IX are 0 and after TitleIX are 1) - Model 1
svy: regress femalepolicyindex white  i.titleIXadult education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister i.parentdaughter c.proportiondaughters  i.firstdaughter i.titleIXadult##i.parentdaughter i.titleIXadult##c.proportiondaughters i.titleIXadult##i.firstdaughter if father==1 & gender==1 & newsexuality==1

*fathers by age (fathers who had children before and after age 25,0 is older than 25 and 1 is 25) - Model 2
svy: regress femalepolicyindex white age  education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter proportiondaughters i.firstdaughter i.youngFather i.youngFather##i.parentdaughter i.youngFather##c.proportiondaughters i.youngFather##i.firstdaughter  if father==1 & gender==1 & newsexuality==1

*Replication for Appendix B
*fathers only for each DV
svy:regress titleix white age education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter proportiondaughters firstdaughter if father==1 & gender==1 & newsexuality==1
svy:regress payequity white age  education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter proportiondaughters firstdaughter  if father==1 & gender==1 & newsexuality==1
svy:regress sexhar white age  education newincome partyid7 newideology religimp genderequalityscale hostilesexismscale married sister parentdaughter proportiondaughters firstdaughter  if father==1 & gender==1 & newsexuality==1



	

